package com.sunny.example;

import java.util.Scanner;

/**
 * 字符串最后一个单词的长度
 */
public class HJ1 {
    public static int getStrLength(String input) {
        if (null == input || "".equals(input)) {
            return 0;
        }
        input = input.trim();
        String[] splits = input.split(" ");
        if (splits.length > 1) {
            String end = splits[splits.length - 1];
            return end.length();
        }

        return splits[0].length();
    }

    public static void main(String[] args) {
        String input = "";
        //在机试中，获取输入可以使用Scanner
        Scanner scanner = new Scanner(System.in);
        input = scanner.nextLine();
        int result = getStrLength(input);
        System.out.println(result);
    }
}
